home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Template / c / ClearAll next >
Text File  |  1995-07-08  |  2KB  |  54 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Template.ClearAll.c
  12.     Author:  Copyright © 1992, 1993, 1994 Jason Williams
  13.              Thanks to John Winters for supplying the code that I hacked
  14.              changed, hacked, rewrote, and then wrote again from scratch!
  15.     Version: 1.20 (24 Apr 1994)
  16.     Purpose: Loading, cacheing, and retrieval of window templates
  17. */
  18.  
  19. #include "TempDefs.h"
  20. #include "DeskLib:Font.h"
  21.  
  22.  
  23. extern void Template_ClearAll(void)
  24. /* Wipes all templates currently known to the system.
  25.  * Deallocates ALL memory used by these templates
  26.  */
  27. {
  28.   template_record *t, *n;
  29.  
  30.   t = (template_record *) template_list.next;
  31.  
  32.   while (t != NULL)
  33.   {
  34.     /*  Free memory used by the template
  35.      *  NOTE that Template_LoadFile allocs 2 meory blocks per template
  36.      *  while cloned templates are fragmented into lots of smaller blocks.
  37.      *  Thus, we must not use Template_Free to deallocate the memory!
  38.      *  (Only LoadFile'd templates can alppear in our template list)
  39.      */
  40.     free(t->windowdef);
  41.     free(t->indirectdata);
  42.  
  43.     n = (template_record *) t->header.next;
  44.     LinkList_Unlink(&template_list, &(t->header));
  45.     free(t);
  46.     t = n;
  47.   }
  48.  
  49.   LinkList_Init(&template_list);         /* just to be on the safe side! */
  50.  
  51.   if ((int) template_fontarray > 0)
  52.     Font_LoseAllFonts(template_fontarray); 
  53. }
  54.